﻿@model KL.Store.Web.Models.CategoryModel
@using KL.Store.Core
@{
    Layout = null;
    string categoryListFullCssClass = "col-xs-12 col-sm-12 col-md-9 col-lg-10 right";
    if (Parameters.Theme == "JB")
    {
        categoryListFullCssClass = "col-xs-12 col-sm-12 col-md-12 col-lg-12 first last";
    }
    else if (Parameters.Theme == "DK" || Parameters.Theme == "EO")
    {
        categoryListFullCssClass = "col-xs-12 col-sm-12 col-md-8 col-lg-9 first last";
    }
    else if (Parameters.Theme == "WU")
    {
        categoryListFullCssClass = "col-xs-12 col-sm-12 col-md-8 col-lg-9";
    }

    string categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-4 col-lg-3";
    short ColumnCount = Model.CategoryType == "M" ? (short)Parameters.BrandListColumnCount : (short)Parameters.CategoryListColumnCount;
    if (ColumnCount == 1)
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-12 col-lg-12";
    }
    else if (ColumnCount == 2)
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-6 col-lg-6";
    }
    else if (ColumnCount == 3)
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-4 col-lg-4";
    }
    else if (ColumnCount == 4)
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-3 col-lg-3";
    }
    else if (ColumnCount == 6)
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-3 col-lg-2";
    }
    else
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-4 col-lg-3";
    }
    if (Parameters.Theme == "DK")
    {
        categoryListColumnCssClass = "col-xs-6 col-sm-6 col-md-3 col-lg-3";
    }
}
<div class="@categoryListFullCssClass">
    @if (Model.BreadCrumb != "")
    {
        <div class="breadcrumb">
            <div class="bcBorder"></div>
            <div class="bcLinks">
                @Html.Raw(Model.BreadCrumb)
            </div>
            <div class="bcBorder"></div>
        </div>
    }
    @if (Model.IsManager || Model.IsSeoManager)
    {
        <div class="edit-genel">
            @if (Model.IsManager)
            {
                <a href="/Products/AddProductToCategory/@(Model.CategoryId)" class="urunEkle fancybox.iframe" title="Kategoriye Ürün Ekle">
                    <i class="fa fa-link fa-2x"></i>
                </a>
                <a href="@Url.Action("Edit", "ProductManage", new { toEdit = "AddNewProduct", id = Model.CategoryId })" class="urunDuzenle fancybox.iframe" title="Yeni Ürün Ekle">
                    <i class="fa fa-plus-square-o fa-2x"></i>
                </a>
            }
            @if (Model.IsSeoManager)
            {
                <a href="/CategoryManage/Edit/@(Model.CategoryId)" class="kategoriDuzenle fancybox.iframe">
                    <i class="fa fa-edit fa-2x"></i>
                </a>
            }
        </div>
    }
    @{if (Model.BannerActive)
      { 
        <div class="hidden-xs hidden-sm col-md-12 col-lg-12 right banner-alt first last">
            <div class="hidden-xs hidden-sm col-md-12 col-lg-12">
                <img src="@(Parameters.WebSiteImageUrl)/category-banner/@(Model.CategoryId).jpg" alt="@Model.CategoryName" />
            </div>
        </div>
        <div class="clearfix"></div>
      }
      else if (Model.ParentBannerActive)
      { 
        <div class="hidden-xs hidden-sm col-md-12 col-lg-12 right banner-alt first last">
            <div class="hidden-xs hidden-sm col-md-12 col-lg-12">
                <img src="@(Parameters.WebSiteImageUrl)/category-banner/@(Model.ParentCategoryId).jpg" alt="@Model.CategoryName" />
            </div>
        </div>
        <div class="clearfix"></div>
      }
    }
    <div class="categories">
        <ul>
            @{ var categoryCounter = 1;
               var categoryListCssClass = ""; }
            @foreach (var item in Model.RelatedCategories)
            {
                if (item.RelatedCategoryCount <= 0 && item.RelatedItemCount <= 0)
                {
                    continue;
                }
                if (categoryCounter % ColumnCount == 0)
                {
                    categoryListCssClass = "inLastColumn";
                }
                else
                {
                    categoryListCssClass = "";
                }
                <li class="@categoryListColumnCssClass @categoryListCssClass">
                    @if (item.RelatedCategoryCount > 0)
                    {
                        <div class="category-outer">
                            <div class="category-inner">
                                <div class="category-image">
                                    <a id="ct_@item.CategoryId" class="cgLink" href="@item.LinkUrl">
                                        <img id="ic_@item.CategoryId" src="@(Parameters.WebSiteImageUrl)/category/@(item.CategoryId).jpg" alt="@item.CategoryName" />
                                        <div class="incele">İncele</div>
                                    </a>
                                </div>
                                <div class="category-title">
                                    <a id="cl_@item.CategoryId" class="cgLink" href="@item.LinkUrl">@item.CategoryName</a>
                                </div>
                            </div>
                        </div>
                    }
                    else
                    {
                        <div class="category-outer">
                            <div class="category-inner">
                                <div class="category-image">
                                    <a id="pr_@item.CategoryId" class="prLink" href="@item.LinkUrl">
                                        <img id="ip_@item.CategoryId" src="@(Parameters.WebSiteImageUrl)/category/@(item.CategoryId).jpg" alt="@item.CategoryName" />
                                        <div class="incele">İncele</div>
                                    </a>
                                </div>
                                <div class="category-title">
                                    <a id="pl_@item.CategoryId" class="prLink" href="@item.LinkUrl">@(item.CategoryName)
                                        @if (Parameters.Theme == "HA")
                                        {
                                            <br />
                                            if (item.RelatedItemCount > 0)
                                            { 
                                            @(item.RelatedItemCount) <span class="productFound">ürün bulunuyor</span>                                            }
                                            else
                                            {
                                            <text>(Ürün yok)</text>
                                            }
                                        }
                                        else
                                        {
                                            if (item.RelatedItemCount > 0)
                                            { 
                                            <text>(</text>@(item.RelatedItemCount)<text>)</text>
                                            }
                                            else
                                            {
                                            <text>(Ürün yok)</text>
                                            }
                                        }
                                    </a>
                                </div>
                            </div>
                        </div>
                    }
                </li>
                    categoryCounter++;
            }
        </ul>
    </div>
    <div class="clearfix"></div>
    @if (Parameters.Theme == "HA")
    {
        @Html.Raw("</div><div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-12\">");
    }
    <div id="products-list-content">
        @{Html.RenderAction("GetProductsInCat", "Categories", new { id = Model.CategoryId, brand = 0, sort = 4, order = 2, itemCount = Parameters.MaxProductCountForCatPage });}
    </div>
</div>
<script type="text/javascript">
    $('a.cgLink222').click(function ()
    {
        var qsId = $(this).attr('id').split("_")[1];
        $('#content').load('/Categories/Get', { id: qsId });
        $('#headermodule').hide();
        if ($(document).scrollTop() > 170)
        {
            $('html, body').animate({ scrollTop: 170 }, 'slow');
        }
        return false;
    });
    $('a.prLink222').click(function ()
    {
        var qsId = $(this).attr('id').split("_")[1];
        $('#content').load('/Products/Get', { id: qsId });
        $('#headermodule').hide();
        if ($(document).scrollTop() > 170)
        {
            $('html, body').animate({ scrollTop: 170 }, 'slow');
        }
        return false;
    });

    $('#headermodule').hide();
    if ($(document).scrollTop() > 170)
    {
        $('html, body').animate({ scrollTop: 170 }, 'slow');
    }
</script>
@if (Parameters.Theme == "JJ")
{
    <script>
        $(document).ready(function ()
        {
            if ($(window).width() < 980)
            {
                $(".breadcrumb").parent().attr("class", $(".breadcrumb").parent().attr("class") + " first last");
            }
        });
    </script>
}
@if (Parameters.WebSiteTrackingCode != "")
{ 
    <script type="text/javascript">

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '@Parameters.WebSiteTrackingCode']);
        _gaq.push(['_setDomainName', '@Parameters.WebSiteTrackingDomainName']);
        _gaq.push(['_setAllowLinker', true]);
        _gaq.push(['_trackPageview']);

        (function ()
        {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    </script>
}